<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>项目审核查看申报</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=10,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="/lib/layui/layui/css/layui.css"/>
    <script type="text/javascript" src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.all.js"></script>
    <script type="text/javascript" src="/js/news/jquery-1.9.1.js"></script>
    <script type="text/javascript" src="/lib/jquery-2.1.4.min.js"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../js/sys/citys.js" type="text/javascript" charset="utf-8"></script>

</head>
<style>
    .mbox {
        padding: 8px;
        background: #fff;
        width: 100%
    }

    .btn {
        height: 30px;
    }

    .btn button {
        float: right;
    }

    .red_12_normal {
        color: red;
    }

    .form {
        font-size: 9pt;
    }

    .form tr {
        height: 60px;
        line-height: 60px;
    }

    .form th {
        position: relative;
        padding-left: 10px;
        text-align: left;
        white-space: nowrap;
        font-weight: normal;
        width: 90px;
        padding-right: 1px;
    }

    .choice, .empty {
        margin-left: 5px;
    }

    .empty {
        color: red;
    }

    .choice {
        color: blue;
    }

    /* 防止下拉框的下拉列表被隐藏---必须设置--- */
    .layui-table-cell {
        overflow: visible !important;
    }

    /* 使得下拉框与单元格刚好合适 */
    td .layui-form-select {
        margin-top: -10px;
        margin-left: -15px;
        margin-right: -15px;
    }

    #form_basic td .layui-form-select {
        margin: 0
    }

    #budgetForm td .layui-form-select {
        margin: 0
    }

    /*解决下拉框被表格覆盖样式问题*/
    .layui-form-select dl {
        z-index: 9999;
    }

    .layui-table-box {
        overflow: visible
    }

    .layui-table-body {
        overflow: visible;
    }

    .layui-form-select .layui-select-title {
        pointer-events: none;
    }
    #ulBox1 .form tbody tr th{
        font-size: 16px;
    }
    #ulBox1 .form tbody tr td input{
        font-size: 16px;
    }
</style>
<body>
<div class="mbox">
    <div class="btn">
        <button type="button" class="layui-btn layui-btn-sm comeback">返回
        </button>
    </div>
    <div class="layui-tab layui-tab-card">
        <ul class="layui-tab-title" id="ulBox">
            <li num="0" class="layui-this">基本信息</li>
            <li num="1">参加者信息</li>
            <li num="2">课题设计论证</li>
            <li num="3">近五年成果</li>
            <li num="4">预计成果</li>
            <li num="5">经费预算</li>
            <li num="6">自我论证</li>
            <li num="7">问题的提出</li>
            <li num="8">研究方案</li>
            <li num="9">预期成果</li>
            <li num="10">原有成果概况</li>
            <li num="11">原有成果奖励及影响</li>
            <li num="12">成果推广应用方案</li>
            <li num="13">成果推广应用的可行性分析</li>
            <li num="14"id="yuqi">上传申请书</li>
        </ul>
        <%--基本信息--%>
        <div class="layui-tab-content" id="ulBox1">
            <div class="layui-tab-item layui-show" num="0">
                <form class="layui-form" id="form_basic" action="/rpmTopic/insetCertificate">
                    <table class="form" style="width: 100%;">
                        <tbody>
                        <tr>
                            <th><span class="red_12_normal">*</span>项目名称</th>
                            <td>
                                <input name="topicName" type="text" class="layui-input required">
                            </td>
                            <th><span class="red_12_normal">*</span>项目类别</th>
                            <td>
                                <select name="topicType" lay-filter="topicType"id="topicType" class="required">
                                    <option value="">请选择</option>
                                </select>
                            </td>
                            <th>研究领域</th>
                            <td>
                                <select name="research">
                                    <option value="">请选择</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <th><span class="red_12_normal">*</span>年度</th>
                            <td>
                                <input name="year" type="text" id="year" class="layui-input required">
                            </td>
                        </tr>
                        <tr><th style="font-size: 18px;font-weight: bold">第一主持人:</th></tr>

                        <tr>
                            <th><span class="red_12_normal">*</span>姓名</th>
                            <td>
                                <input name="" type="text" id="userId"
                                       class="layui-input required" disabled="disabled">
                            </td>
                            <th><span class="red_12_normal">*</span>学段</th>
                            <td>
                                <select name="sectionType" class="required">
                                    <option value="">请选择</option>
                                </select>
                            </td>
                            <th><span class="red_12_normal">*</span>任教学科</th>
                            <td>
                                <select name="teachingSubjects" class="required">
                                    <option value="">请选择</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <th><span class="red_12_normal">*</span>行政职务</th>
                            <td>
                                <select name="administrativePosition" class="required">
                                    <option value="">请选择</option>
                                </select>
                            </td>
                            <th>专业职务</th>
                            <td>
                                <select name="professionalPosition" class="required">
                                    <option value="">请选择</option>
                                </select>
                            </td>
                            <th><span class="red_12_normal">*</span>专业职称</th>
                            <td>
                                <select name="professionalTitle" class="required">
                                    <option value="">请选择</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <th>单位名称</th>
                            <td>
                                <input name="unitName" type="text" class="layui-input"disabled>
                            </td>
                            <th>学历</th>
                            <td>
                                <input name="education" type="text" class="layui-input">
                            </td>
                            <th>联系电话</th>
                            <td>
                                <input name="contactNumber" type="text" class="layui-input">
                            </td>
                        </tr>
                        <tr>
                            <th>通讯地址</th>
                            <td>
                                <input name="postalAddress" type="text" class="layui-input"></td>
                            <th>研究特长</th>
                            <td>
                                <input name="researchExpertise" type="text" class="layui-input">
                            </td>
                            <th>教龄</th>
                            <td>
                                <input name="teachingYears" type="text" class="layui-input">
                            </td>
                        </tr>
                        <tr>
                            <th>邮政编码</th>
                            <td>
                                <input name="postalCode" type="text" class="layui-input">
                            </td>
                        </tr>
                        <tr><th style="font-size: 18px;font-weight: bold">第二主持人:</th></tr>
                        <tr>
                            <th>是否有第二主持人</th>
                            <td>
                                    <span disabled="disabled">
                                        <input type="radio" name="haveSecondUserId" lay-filter="haveSecondUserId" value="1" title="是">
                                        <input type="radio" name="haveSecondUserId" lay-filter="haveSecondUserId" value="0" title="否" checked>
                                    </span>
                            </td>

                            <th><span class="red_12_normal">*</span>第二主持人</th>
                            <td>
                                <input name="" style="display: inline-block;background:gainsboro;width: 68%;" type="text" id="headUserId2"
                                       disabled="disabled" class="layui-input required">
                                <a href="#" class="choice" style="display: none">选择</a>
                                <a href="#" class="empty3" style="display: none">清空</a>
                            </td>
                        </tr>
                        <tr class="second" style="display: none">
                            <th>教龄</th>
                            <td>
                                <input name="teachingYears1" type="text" class="layui-input">
                            </td>
                            <th><span class="red_12_normal">*</span>任教学科</th>
                            <td>
                                <select name="teachingSubjects1" class="required">
                                    <option value="">请选择</option>
                                </select>
                            </td>
                            <th><span class="red_12_normal">*</span>行政职务</th>
                            <td>
                                <select name="administrativePosition1" class="required">
                                    <option value="">请选择</option>
                                </select>
                            </td>
                        </tr>
                        <tr class="second" style="display: none">
                            <th>专业职务</th>
                            <td>
                                <select name="professionalPosition1" class="required">
                                    <option value="">请选择</option>
                                </select>
                            </td>
                            <th><span class="red_12_normal">*</span>专业职称</th>
                            <td>
                                <select name="professionalTitle1" class="required">
                                    <option value="">请选择</option>
                                </select>
                            </td>
                            <th>研究特长</th>
                            <td>
                                <input name="researchExpertise1" type="text" class="layui-input">
                            </td>
                        </tr>
                        <tr class="second" style="display: none">
                            <th>单位名称</th>
                            <td>
                                <input name="unitName1" type="text" class="layui-input"disabled>
                            </td>
                            <th>联系电话</th>
                            <td>
                                <input name="contactNumber1" type="text" class="layui-input">
                            </td>
                            <th>邮政编码</th>
                            <td>
                                <input name="postalCode1" type="text" class="layui-input">
                            </td>
                        </tr>
                        <tr class="second" style="display: none">
                            <th>通讯地址</th>
                            <td>
                                <input name="postalAddress1" type="text" class="layui-input"></td>
                            <th><span class="red_12_normal">*</span>学段</th>
                            <td>
                                <select name="sectionType1" class="required">
                                    <option value="">请选择</option>
                                </select>
                            </td>
                        </tr>
                        <tr><th style="font-size: 18px;font-weight: bold">成果推广:</th></tr>
                        <tr>
                            <th>是否跨校合作研究</th>
                            <td>
                               <span id="rdoSex" disabled="disabled">
                                        <input type="radio" name="isCrossSchool" value="1" title="是" checked>
                                        <input type="radio" name="isCrossSchool" value="0" title="否">
                                    </span>
                            </td>
                            <th><span class="red_12_normal">*</span>成果应用研究领衔人</th>
                            <td>
                                <input name="" style="display: inline-block;width: 68%;" disabled="disabled" type="text"
                                       id="applicationLeader" class="layui-input required">
                                <a href="#" class="choice">选择</a>
                                <a href="#" class="empty">清空</a>
                            </td>
                            <th>单位</th>
                            <td>
                                <input name="applicationLeaderDept" disabled="disabled" id="applicationLeaderDept" type="text" class="layui-input" disabled="disabled">
                            </td>
                        </tr>
                        <tr>
                            <th><span class="red_12_normal">*</span>成果推广研究领衔人</th>
                            <td>
                                <input name="" style="display: inline-block;width: 68%;" type="text" disabled="disabled"
                                       id="promotionLeader" class="layui-input required">
                                <a href="#" class="choice">选择</a>
                                <a href="#" class="empty1">清空</a>
                            </td>

                            <th>单位</th>
                            <td>
                                <input name="promotionLeaderDept" disabled="disabled" type="text" class="layui-input">
                            </td>
                        </tr>
                        <tr>
                            <th><span class="red_12_normal">*</span>原成果名称</th>
                            <td colspan="3">
                                <input name="achievementsName" type="text" class="layui-input"></td>
                            <th><span class="red_12_normal">*</span>原成果持有者</th>
                            <td>
                                <input name="" style="display: inline-block;width: 68%;" type="text" id="holderName"
                                       disabled="disabled" class="layui-input required">
                                <a href="#" class="choice">选择</a>
                                <a href="#" class="empty4">清空</a>
                            </td>
                        </tr>
                        <tr>
                            <th><span class="red_12_normal">*</span>推广范围</th>
                            <td colspan="3">
                                <input name="promotionScope" type="text" class="layui-input"></td>
                            <th><span class="red_12_normal">*</span>起止时间</th>
                            <td>
                                <input name="startingEndingTime" id="startingEndingTime" type="text"
                                       class="layui-input">
                            </td>
                        </tr>

                        </tbody>
                    </table>
                </form>
            </div>
            <%--主参加者信息--%>
            <div class="layui-tab-item" num="1">
                <div class="wordText">基本信息选择项目类别为重点课题、一般课题、重点项目，主要参加信息最多只能加11项</div>
                <table class="layui-hide" id="participator" lay-filter="participator"></table>
            </div>
            <%--课题设计论证--%>
            <div class="layui-tab-item" num="2">
                <div style="padding: 20px 20px">
                    <p style="font-weight:bold;text-align:center;font-size:22px;margin-bottom: 30px">课题设计论证</p>
                    <p style="font-weight:bold;font-size:18px;margin-bottom: 20px">情报综述</p>
                    <div style="margin-bottom: 6px">本课题相关国内外研究情报述评</div>
                    <textarea class="informationReview" style="width:80%;border: 1px solid #eeeeee;height: 60px"></textarea>
                    <p style="font-weight:bold;font-size:18px;margin-bottom: 20px;margin-top: 5px">研究方案</p>
                    <div style="margin-bottom: 6px">
                        1.本课题核心概念的界定，选题意义及研究价值<br/>
                        2.本课题的研究目标、研究内容、研究方法、实施步骤<br/>
                        3.本课题的关键问题和拟创新点<br/>
                        4.预计成果<br/>
                    </div>
                    <textarea class="researchPlan" style="border: 1px solid #eeeeee;width:80%;height: 80px"></textarea>
                </div>
            </div>
            <%--近五年成果--%>
            <div class="layui-tab-item" num="3">
                <table class="layui-hide" id="achievement" lay-filter="achievement"></table>
            </div>
            <%--预计成果--%>
            <div class="layui-tab-item" num="4">
                <div style="text-align: center;font-size: 22px;">阶段性成果</div>
                <table class="layui-hide" id="expect" lay-filter="expect"></table>
                <div style="text-align: center;font-size: 22px;">最终研究成果</div>
                <table class="layui-hide" id="fnexpect" lay-filter="fnexpect"></table>
            </div>
            <%--经费预算--%>
            <div class="layui-tab-item" num="5">
                <button onclick="instruct()">经费预算说明</button>
                <table class="layui-hide" id="task" lay-filter="task"></table>
            </div>
            <%--自我论证--%>
            <div class="layui-tab-item" num="6">
                <div style="padding: 20px 20px">
                    <p style="font-weight:bold;font-size:18px;margin-bottom: 20px">自我论证</p>
                    <textarea class="selfArgument" style="border: 1px solid #eeeeee;width:80%;height: 80px">
                    </textarea>
                </div>
            </div>
            <%--问题的提出--%>
            <div class="layui-tab-item" num="7">
                <div style="padding: 20px 20px">
                    <p style="text-align: center;font-weight:bold;font-size:22px;margin-bottom: 30px">问题的提出</p>
                    1、核心概念界定——从课题名称中提取本课题的关键词，并进行界定。<br/>
                    2、问题的描述与分析——描述自身教育教学过程中发现的问题，并对该问题进行分析。<br/>
                    3、国内外相关研究述评——围绕关键词分别进行文献研究，最后对总体研究现状进行评论。<br/>
                    4、本课题的突破与创新——基于文献研究的结果，阐述本课题的创新点和突破口。<br/>
                    5、已有研究基础（如有）——自身或所在学校与本课题有关的已有研究。<br/>
                    <textarea class="askQuestions" style="width:80%;margin-top:6px;border: 1px solid #eeeeee;height: 60px"></textarea>
                </div>
            </div>
            <%--研究方案--%>
            <div class="layui-tab-item" num="8">
                <div style="padding: 20px 20px">
                    <p style="text-align: center;font-weight:bold;font-size:22px;margin-bottom: 30px">研究方案</p>
                    1、研究目标——应包含直接目标和间接目标。<br/>
                    2、研究内容——围绕课题名称，本课题所要回答的若干个小问题。<br/>
                    3、研究方法——本课题所采用的研究方法的名称，及其在本课题中的具体运用打算。<br/>
                    4、研究步骤——研究进度、研究活动的分阶段安排。<br/>
                    <textarea id="researchPlan" style="border: 1px solid #eeeeee;width:80%;height: 80px"></textarea>
                </div>

            </div>
            <div class="layui-tab-item" num="9">
                <div style="padding: 20px 20px">
                    <p style="font-weight:bold;font-size:18px;margin-bottom: 20px">预期成果</p>
                    <textarea  class="expectedResults" style="border: 1px solid #eeeeee;width:80%;height: 80px">
                    </textarea>
                </div>
            </div>
            <%--原有成果概况--%>
            <div class="layui-tab-item" num="10">
                <div style="padding: 20px 20px">
                    <p style="font-weight:bold;font-size:22px;margin-bottom: 30px">原有成果概况</p>
                    <div>1、简要介绍拟推广的原有成果的主要内容、意义与价值</div>
                    <textarea class="achievementsSurvey" style="width:80%;margin-top:8px;border: 1px solid #eeeeee;height: 60px"></textarea>
                </div>
            </div>
            <%--原有成果奖励及影响--%>
            <div class="layui-tab-item" num="11">
                <div style="margin-left: 20px">注意：以下四项必须填一项</div>
                <table class="layui-hide" id="yexpect1" lay-filter="yexpect1"></table>
                <table class="layui-hide" id="yexpect2" lay-filter="yexpect2"></table>
                <table class="layui-hide" id="yexpect3" lay-filter="yexpect3"></table>
                <table class="layui-hide" id="yexpect4" lay-filter="yexpect4"></table>
                <div style="text-align: center;font-weight: bold;font-size: 18px;margin: 18px 0;">可以证明成果影响的其他方面消息</div>
                <textarea id="number" style="width:100%;margin-top:8px;border: 1px solid #eeeeee;height: 100px"></textarea>
            </div>
            <%--成果推广应用方案--%>
            <div class="layui-tab-item" num="12">
                <div style="padding: 20px 20px">
                    <p style="font-weight:bold;font-size:22px;margin-bottom: 30px">成果推广应用方案</p>
                    <div>
                        1．推广应用目标的预设（为什么要推广应用该项成果，要解决的问题和要达到的主要目标）<br/>
                        2．推广应用内容的确定（对原有研究成果的哪些内容进行应用、发展、完善与转化）<br/>
                        3．推广应用的范围与对象（区域、学校、学科、年级、班级、教研组等）<br/>
                        4．推广应用方法的选择（用哪些方法、策略或途径推广应用该成果）<br/>
                        5．推广应用实施计划（分为几个环节，用什么方法，在哪段时间完成什么任务）</div>
                    <textarea class="achievementsApplicationScheme" style="width:80%;margin-top:10px;border: 1px solid #eeeeee;height: 60px"></textarea>
                </div>
            </div>
            <%--成果推广应用的可行性分析--%>
            <div class="layui-tab-item" num="13">
                <div style="padding: 20px 20px">
                    <p style="font-weight:bold;font-size:22px;margin-bottom: 30px">成果推广应用的可行性分析</p>
                    <div>
                        对推广应用该项教育科研成果所具有的主客观条件等进行分析，<br/>
                        包括应用场景转换后可能遭遇的主要困难的预估及解决方案。</div>
                    <textarea class="achievementsApplicationSchemeAnalysis" style="width:80%;margin-top:10px;border: 1px solid #eeeeee;height: 60px"></textarea>
                </div>
            </div>
            <%--上传申请书--%>
            <div class="layui-tab-item" num="14">
                <div class="content">
                    <form class="layui-form" action="">
                        <button type="button" class="layui-btn layui-btn-normal" id="uploading"><i
                                class="layui-icon"></i>上传申请书
                        </button>
                        <div style="margin: 20px 0;display: none">
                        </div>
                    </form>
                </div>
            </div>

        </div>
    </div>
</div>
</body>
</html>
<script>
    var parName = [];
/*
    $('.layui-tab-content').height($(window).height() - 30);
*/
    layui.use(['table', 'form', 'laydate', 'upload', 'element'], function () {
        var element = layui.element;
        var table = layui.table,
            form = layui.form,
            laydate = layui.laydate,
            upload = layui.upload
            var keti;
            var question;
            var original;
            var harvet;

        //年范围
        laydate.render({
            elem: '#year'
            , type: 'year'
        });
        laydate.render({
            elem: '#startingEndingTime'
        });
        laydate.render({
            elem: '#completionTime'
        });
        $('#form_basic input').attr('disabled', 'disabled')
        $('#form_basic select').attr('disabled', 'disabled')
        $('#budgetForm input').attr('disabled', 'disabled')
        $('#budgetForm select').attr('disabled', 'disabled')
        form.render('select');
        //默认申请人是当前登录人
        $.ajax({
            url: '/Meetequipment/getuser',
            type: 'get',
            dataType: 'json',
            success: function (res) {
                //申报人
                $('#userId').attr('user_id', res.object.userId + ',');
                $('#userId').attr('dataid', res.object.uid + ',');
                $('#userId').val(res.object.userName + ',');
                //负责人
                $('#headUserId').attr('user_id', res.object.userId + ',');
                $('#headUserId').attr('dataid', res.object.uid + ',');
                $('#headUserId').val(res.object.userName + ',');
            }
        })

        // 获取地址栏参数值
        function getQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]);
            return null;
        }

        var trId = getQueryString("trId");
        var type = getQueryString("btype");

        $('.comeback').click(function () {
            if (getQueryString('type') == 1) {
                window.location.href = '/rpmPlan/rpmAudit'
            } else if (getQueryString('type') == 2) {
                window.location.href = '/rpmPlan/rpmCollegeTeacher'
            } else {
                window.location.href = '/rpmPlan/rpmDirectorResearch'
            }

        })

        var achievementsTypeSel, topicCategorySel, memberTypeSel, expenditureCategorySel;
        form.render()
        $.ajax({
            url: '/rpmTopic/selectByparentNo',
            type: 'get',
            dataType: 'json',
            async: false,
            success: function (res) {
                achievementsTypeSel = res.data.achievementsType
                topicCategorySel = res.data.projectType
                memberTypeSel = res.data.memberType
                expenditureCategorySel = res.data.budgetType
                for (var i = 0; i < res.data.researchType.length; i++) {
                    $('[name="research"]').append('<option value="' + res.data.researchType[i].dictNo + '">' + res.data.researchType[i].dictName + '</option>')
                    form.render()
                }
                for (var i = 0; i < res.data.projectType.length; i++) {
                    $('[name="topicType"]').append('<option value="' + res.data.projectType[i].dictNo + '">' + res.data.projectType[i].dictName + '</option>')
                    form.render()
                }
                // 支出类别
                for (var i = 0; i < res.data.budgetType.length; i++) {
                    $('[name="expenditureCategory"]').append('<option value="' + res.data.budgetType[i].dictNo + '">' + res.data.budgetType[i].dictName + '</option>')
                    form.render()
                }

                for (var i = 0; i < res.data.achievementsType.length; i++) {
                    $('[name="achievementsType"]').append('<option value="' + res.data.achievementsType[i].dictNo + '">' + res.data.achievementsType[i].dictName + '</option>')
                    form.render()
                }
                for (var i = 0; i < res.data.sectionType.length; i++) {
                    $('[name="sectionType"]').append('<option value="' + res.data.sectionType[i].dictNo + '">' + res.data.sectionType[i].dictName + '</option>')
                    form.render()
                }
                // 第二主持人学段
                for (var i = 0; i < res.data.sectionType.length; i++) {
                    $('[name="sectionType1"]').append('<option value="' + res.data.sectionType[i].dictNo + '">' + res.data.sectionType[i].dictName + '</option>')
                    form.render()
                }
                for (var i = 0; i < res.data.teachingSubjectsType.length; i++) {
                    $('[name="teachingSubjects"]').append('<option value="' + res.data.teachingSubjectsType[i].dictNo + '">' + res.data.teachingSubjectsType[i].dictName + '</option>')
                    form.render()
                }
                // 第二主持人任教学科
                for (var i = 0; i < res.data.teachingSubjectsType.length; i++) {
                    $('[name="teachingSubjects1"]').append('<option value="' + res.data.teachingSubjectsType[i].dictNo + '">' + res.data.teachingSubjectsType[i].dictName + '</option>')
                    form.render()
                }
                for (var i = 0; i < res.data.administrativePositionType.length; i++) {
                    $('[name="administrativePosition"]').append('<option value="' + res.data.administrativePositionType[i].dictNo + '">' + res.data.administrativePositionType[i].dictName + '</option>')
                    form.render()
                }
                // 第二主持人行政职务
                for (var i = 0; i < res.data.administrativePositionType.length; i++) {
                    $('[name="administrativePosition1"]').append('<option value="' + res.data.administrativePositionType[i].dictNo + '">' + res.data.administrativePositionType[i].dictName + '</option>')
                    form.render()
                }
                for (var i = 0; i < res.data.professionalPositionType.length; i++) {
                    $('[name="professionalPosition"]').append('<option value="' + res.data.professionalPositionType[i].dictNo + '">' + res.data.professionalPositionType[i].dictName + '</option>')
                    form.render()
                }
                // 第二主持专业职务
                for (var i = 0; i < res.data.professionalPositionType.length; i++) {
                    $('[name="professionalPosition1"]').append('<option value="' + res.data.professionalPositionType[i].dictNo + '">' + res.data.professionalPositionType[i].dictName + '</option>')
                    form.render()
                }
                for (var i = 0; i < res.data.professionalTitleType.length; i++) {
                    $('[name="professionalTitle"]').append('<option value="' + res.data.professionalTitleType[i].dictNo + '">' + res.data.professionalTitleType[i].dictName + '</option>')
                    form.render()
                }
                // 第二主持专业职称
                for (var i = 0; i < res.data.professionalTitleType.length; i++) {
                    $('[name="professionalTitle1"]').append('<option value="' + res.data.professionalTitleType[i].dictNo + '">' + res.data.professionalTitleType[i].dictName + '</option>')
                    form.render()
                }
            }
        })

        form.on('select(topicType)', function(data){
            if(data.value == "PROJECT_TYPE1" || data.value == "PROJECT_TYPE2" || data.value == "PROJECT_TYPE3"){
                $("#ulBox").find("li[num=0]").css("display","");
                $("#ulBox").find("li[num=1]").css("display","");
                $("#ulBox").find("li[num=2]").css("display","");
                $("#ulBox").find("li[num=3]").css("display","");
                $("#ulBox").find("li[num=4]").css("display","");
                $("#ulBox").find("li[num=5]").css("display","");
                $("#ulBox").find("li[num=6]").css("display","");
                $("#ulBox").find("li[num=7]").css("display","none");
                $("#ulBox").find("li[num=8]").css("display","none");
                $("#ulBox").find("li[num=9]").css("display","none");
                $("#ulBox").find("li[num=10]").css("display","none");
                $("#ulBox").find("li[num=11]").css("display","none");
                $("#ulBox").find("li[num=12]").css("display","none");
                $("#ulBox").find("li[num=13]").css("display","none");
                $("#ulBox").find("li[num=14]").css("display","");

                $("#ulBox1").find("div[num=0]").css("display","");
                $("#ulBox1").find("div[num=1]").css("display","");
                $("#ulBox1").find("div[num=2]").css("display","");
                $("#ulBox1").find("div[num=3]").css("display","");
                $("#ulBox1").find("div[num=4]").css("display","");
                $("#ulBox1").find("div[num=5]").css("display","");
                $("#ulBox1").find("div[num=6]").css("display","");
                $("#ulBox1").find("div[num=7]").css("display","none");
                $("#ulBox1").find("div[num=8]").css("display","none");
                $("#ulBox1").find("div[num=9]").css("display","none");
                $("#ulBox1").find("div[num=10]").css("display","none");
                $("#ulBox1").find("div[num=11]").css("display","none");
                $("#ulBox1").find("div[num=12]").css("display","none");
                $("#ulBox1").find("div[num=13]").css("display","none");
                $("#ulBox1").find("div[num=14]").css("display","");
            }else if(data.value == "PROJECT_TYPE4" ){
                $("#ulBox").find("li[num=0]").css("display","");
                $("#ulBox").find("li[num=1]").css("display","");
                $("#ulBox").find("li[num=5]").css("display","");
                $("#ulBox").find("li[num=7]").css("display","");
                $("#ulBox").find("li[num=8]").css("display","");
                $("#ulBox").find("li[num=9]").css("display","");
                $("#ulBox").find("li[num=14]").css("display","");
                $("#ulBox").find("li[num=2]").css("display","none");
                $("#ulBox").find("li[num=3]").css("display","none");
                $("#ulBox").find("li[num=4]").css("display","none");
                $("#ulBox").find("li[num=6]").css("display","none");
                $("#ulBox").find("li[num=10]").css("display","none");
                $("#ulBox").find("li[num=11]").css("display","none");
                $("#ulBox").find("li[num=12]").css("display","none");
                $("#ulBox").find("li[num=13]").css("display","none");

                $("#ulBox1").find("div[num=0]").css("display","");
                $("#ulBox1").find("div[num=1]").css("display","");
                $("#ulBox1").find("div[num=5]").css("display","");
                $("#ulBox1").find("div[num=7]").css("display","");
                $("#ulBox1").find("div[num=8]").css("display","");
                $("#ulBox1").find("div[num=9]").css("display","");
                $("#ulBox1").find("div[num=14]").css("display","");
                $("#ulBox1").find("div[num=2]").css("display","none");
                $("#ulBox1").find("div[num=3]").css("display","none");
                $("#ulBox1").find("div[num=4]").css("display","none");
                $("#ulBox1").find("div[num=6]").css("display","none");
                $("#ulBox1").find("div[num=10]").css("display","none");
                $("#ulBox1").find("div[num=11]").css("display","none");
                $("#ulBox1").find("div[num=12]").css("display","none");
                $("#ulBox1").find("div[num=13]").css("display","none");

            }else if(data.value == "PROJECT_TYPE5" ){
                $("#ulBox").find("li[num=0]").css("display","");
                $("#ulBox").find("li[num=1]").css("display","");
                $("#ulBox").find("li[num=5]").css("display","");
                $("#ulBox").find("li[num=4]").css("display","");
                $("#ulBox").find("li[num=10]").css("display","");
                $("#ulBox").find("li[num=11]").css("display","");
                $("#ulBox").find("li[num=12]").css("display","");
                $("#ulBox").find("li[num=13]").css("display","");
                $("#ulBox").find("li[num=14]").css("display","");
                $("#ulBox").find("li[num=2]").css("display","none");
                $("#ulBox").find("li[num=3]").css("display","none");
                $("#ulBox").find("li[num=9]").css("display","none");
                $("#ulBox").find("li[num=6]").css("display","none");
                $("#ulBox").find("li[num=7]").css("display","none");
                $("#ulBox").find("li[num=8]").css("display","none");

                $("#ulBox1").find("div[num=0]").css("display","");
                $("#ulBox1").find("div[num=1]").css("display","");
                $("#ulBox1").find("div[num=5]").css("display","");
                $("#ulBox1").find("div[num=4]").css("display","");
                $("#ulBox1").find("div[num=10]").css("display","");
                $("#ulBox1").find("div[num=11]").css("display","");
                $("#ulBox1").find("div[num=12]").css("display","");
                $("#ulBox1").find("div[num=13]").css("display","");
                $("#ulBox1").find("div[num=14]").css("display","");
                $("#ulBox1").find("div[num=2]").css("display","none");
                $("#ulBox1").find("div[num=3]").css("display","none");
                $("#ulBox1").find("div[num=9]").css("display","none");
                $("#ulBox1").find("div[num=6]").css("display","none");
                $("#ulBox1").find("div[num=7]").css("display","none");
                $("#ulBox1").find("div[num=8]").css("display","none");

            }
        });
        function GetQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);

            if (r != null) {
                return unescape(r[2]);
            } else {
                return null;
            }
        }
        form.on('radio(haveSecondUserId)', function (data) {
            // 无第二主持人
            if (data.value == 0) {
                $('#headUserId2').val('').attr('user_Id', '').css('background', 'gainsboro').siblings('a').hide()
                $('.second').hide();
                // 有第二主持人
            } else {
                $('#headUserId2').css('background', '#fff').siblings('a').show()
                $('.second').show();
            }
        });
        $.ajax({
            url: '/rpmTopic/selectByTopicId',
            data: {
                planId: GetQueryString('planId'),
                userId: GetQueryString('userId')
            },
            type: 'post',
            dataType: 'json',
            success: function (res) {
                var rpmTopic = res.data.rpmTopic
                if (res.msg != 'err') {
                    var rpmTopic = res.data.rpmTopic
                    var topicId = res.data.rpmTopic.topicId
                    $('.add').attr('topicId', res.data.rpmTopic.topicId)
                    var participator = res.data.rpmSignatures
                    var achievement = res.data.rpmForecasts
                    var task = res.data.rpmBudgets
                    var expect = res.data.rpmExpectedResults
                    var yexpect = res.data.rpmAchievementsAwards
                    keti = res.data.rpmProjectDemonstrations
                    question=res.data.rpmProgrammes
                    original=res.data.rpmAchievementsPromotions
                    harvet=res.data.rpmAchievementsAwards
                    if(harvet.length>0){
                        for(var i=0;i<harvet.length;i++){
                            $("#number").val(harvet[i].number)
                        }

                    }
                    if (keti.length > 0) {
                        $(".informationReview").val(keti[0].informationReview)
                        $(".researchPlan").val(keti[0].researchPlan)
                        $(".selfArgument").val(keti[0].selfArgument)
                    }
                    if(question.length>0){
                        if(question[0].askQuestions!=""||question[0].askQuestions!=undefined){
                            $(".askQuestions").val(question[0].askQuestions)
                        }
                        if(question[0].researchPlan!=""||question[0].researchPlan!=undefined) {
                            $("#researchPlan").val(question[0].researchPlan)
                        }
                        if(question[0].expectedResults!=""||question[0].researchPlan!=undefined){
                            $(".expectedResults").val(question[0].expectedResults)
                        }
                    }

                    if(original.length>0){
                        if(original[0].achievementsSurvey!=""||original[0].achievementsSurvey!=undefined){
                            $(".achievementsSurvey").val(original[0].achievementsSurvey)
                        }
                        if(original[0].achievementsApplicationScheme!=""||original[0].achievementsApplicationScheme!=undefined) {
                            $(".achievementsApplicationScheme").val(original[0].achievementsApplicationScheme)
                        }
                        if(original[0].achievementsApplicationSchemeAnalysis!=""||original[0].achievementsApplicationSchemeAnalysis!=undefined){
                            $(".achievementsApplicationSchemeAnalysis").val(original[0].achievementsApplicationSchemeAnalysis)
                        }
                    }
                    tableData(topicId, participator, achievement, task, expect,yexpect)
                    //基本信息
                    $('[name="professionalPosition"]').val(rpmTopic.professionalPosition)
                    $('[name="achievementsName"]').val(rpmTopic.achievementsName)
                    $('[name="contactNumber"]').val(rpmTopic.contactNumber)
                    $('[name="postalAddress"]').val(rpmTopic.postalAddress)
                    $('[name="unitName"]').val(rpmTopic.unitName)
                    $('[name="unitName1"]').val(rpmTopic.unitName1)
                    $('[name="postalCode"]').val(rpmTopic.postalCode)
                    $('[name="applicationLeaderDept"]').val(rpmTopic.applicationLeaderDept)
                    $('[name="promotionLeaderDept"]').val(rpmTopic.promotionLeaderDept)
                    $('[name="promotionScope"]').val(rpmTopic.promotionScope)
                    $('[name="research"]').val(rpmTopic.research)
                    $('[name="sectionType"]').val(rpmTopic.sectionType)
                    $('[name="startingEndingTime"]').val(rpmTopic.startingEndingTime)
                    $('[name="teachingSubjects"]').val(rpmTopic.teachingSubjects)
                    $('[name="teachingYears"]').val(rpmTopic.teachingYears)
                    $('[name="teachingYears1"]').val(rpmTopic.teachingYears1)
                    $('[name="teachingSubjects1"]').val(rpmTopic.teachingSubjects1)
                    $('[name="administrativePosition1"]').val(rpmTopic.administrativePosition1)
                    $('[name="professionalPosition1"]').val(rpmTopic.professionalPosition1)
                    $('[name="professionalTitle1"]').val(rpmTopic.professionalTitle1)
                    $('[name="researchExpertise1"]').val(rpmTopic.researchExpertise1)
                    $('[name="contactNumber1"]').val(rpmTopic.contactNumber1)
                    $('[name="postalCode1"]').val(rpmTopic.postalCode1)
                    $('[name="postalAddress1"]').val(rpmTopic.postalAddress1)
                    $('[name="sectionType1"]').val(rpmTopic.sectionType1)
                    $('[name="topicName"]').val(rpmTopic.topicName)
                    $('[name="year"]').val(rpmTopic.year)
                    $('[name="reviewFraction"]').val(rpmTopic.reviewFraction)
                    $('[name="education"]').val(rpmTopic.education)
                    $('#userId').val(rpmTopic.userName).attr('user_Id', rpmTopic.userId)
                    $('#headUserId').val(rpmTopic.userName).attr('user_Id', rpmTopic.headUserId)
                    $('#promotionLeader').val(rpmTopic.promotionUserName).attr('user_Id', rpmTopic.promotionLeader)
                    $('#headUserId2').val(rpmTopic.headUserName2).attr('user_Id', rpmTopic.headUserId2)
                    $('#applicationLeader').val(rpmTopic.applicationUserName).attr('user_Id', rpmTopic.applicationLeader)
                    $('#holderName').val(rpmTopic.holderUserName).attr('user_Id', rpmTopic.holderName)

                    $('[name="researchExpertise"]').val(rpmTopic.researchExpertise)
                    $('[name="applicationLeaderSept"]').val(rpmTopic.applicationLeaderSept)
                    $('[name="topicType"]').val(rpmTopic.topicType)
                    $('[name="professionalTitle"]').val(rpmTopic.professionalTitle)
                    $('[name="administrativePosition"]').val(rpmTopic.administrativePosition)
                    $('[name="haveSecondUserId"][value="' + rpmTopic.haveSecondUserId + '"]').prop('checked', true);
                    $('[name="isCrossSchool"][value="' + rpmTopic.isCrossSchool + '"]').prop('checked', true);

                    if(rpmTopic.topicType == "PROJECT_TYPE1" || rpmTopic.topicType == "PROJECT_TYPE2" || rpmTopic.topicType == "PROJECT_TYPE3"){
                        $("#ulBox").find("li[num=0]").css("display","");
                        $("#ulBox").find("li[num=1]").css("display","");
                        $("#ulBox").find("li[num=2]").css("display","");
                        $("#ulBox").find("li[num=3]").css("display","");
                        $("#ulBox").find("li[num=4]").css("display","");
                        $("#ulBox").find("li[num=5]").css("display","");
                        $("#ulBox").find("li[num=6]").css("display","");
                        $("#ulBox").find("li[num=7]").css("display","none");
                        $("#ulBox").find("li[num=8]").css("display","none");
                        $("#ulBox").find("li[num=9]").css("display","none");
                        $("#ulBox").find("li[num=10]").css("display","none");
                        $("#ulBox").find("li[num=11]").css("display","none");
                        $("#ulBox").find("li[num=12]").css("display","none");
                        $("#ulBox").find("li[num=13]").css("display","none");
                        $("#ulBox").find("li[num=14]").css("display","");

                        $("#ulBox1").find("div[num=0]").css("display","");
                        $("#ulBox1").find("div[num=1]").css("display","");
                        $("#ulBox1").find("div[num=2]").css("display","");
                        $("#ulBox1").find("div[num=3]").css("display","");
                        $("#ulBox1").find("div[num=4]").css("display","");
                        $("#ulBox1").find("div[num=5]").css("display","");
                        $("#ulBox1").find("div[num=6]").css("display","");
                        $("#ulBox1").find("div[num=7]").css("display","none");
                        $("#ulBox1").find("div[num=8]").css("display","none");
                        $("#ulBox1").find("div[num=9]").css("display","none");
                        $("#ulBox1").find("div[num=10]").css("display","none");
                        $("#ulBox1").find("div[num=11]").css("display","none");
                        $("#ulBox1").find("div[num=12]").css("display","none");
                        $("#ulBox1").find("div[num=13]").css("display","none");
                        $("#ulBox1").find("div[num=14]").css("display","");
                    }else if(rpmTopic.topicType == "PROJECT_TYPE4" ){
                        $("#ulBox").find("li[num=0]").css("display","");
                        $("#ulBox").find("li[num=1]").css("display","");
                        $("#ulBox").find("li[num=5]").css("display","");
                        $("#ulBox").find("li[num=7]").css("display","");
                        $("#ulBox").find("li[num=8]").css("display","");
                        $("#ulBox").find("li[num=9]").css("display","");
                        $("#ulBox").find("li[num=14]").css("display","");
                        $("#ulBox").find("li[num=2]").css("display","none");
                        $("#ulBox").find("li[num=3]").css("display","none");
                        $("#ulBox").find("li[num=4]").css("display","none");
                        $("#ulBox").find("li[num=6]").css("display","none");
                        $("#ulBox").find("li[num=10]").css("display","none");
                        $("#ulBox").find("li[num=11]").css("display","none");
                        $("#ulBox").find("li[num=12]").css("display","none");
                        $("#ulBox").find("li[num=13]").css("display","none");

                        $("#ulBox1").find("div[num=0]").css("display","");
                        $("#ulBox1").find("div[num=1]").css("display","");
                        $("#ulBox1").find("div[num=5]").css("display","");
                        $("#ulBox1").find("div[num=7]").css("display","");
                        $("#ulBox1").find("div[num=8]").css("display","");
                        $("#ulBox1").find("div[num=9]").css("display","");
                        $("#ulBox1").find("div[num=14]").css("display","");
                        $("#ulBox1").find("div[num=2]").css("display","none");
                        $("#ulBox1").find("div[num=3]").css("display","none");
                        $("#ulBox1").find("div[num=4]").css("display","none");
                        $("#ulBox1").find("div[num=6]").css("display","none");
                        $("#ulBox1").find("div[num=10]").css("display","none");
                        $("#ulBox1").find("div[num=11]").css("display","none");
                        $("#ulBox1").find("div[num=12]").css("display","none");
                        $("#ulBox1").find("div[num=13]").css("display","none");
                    }else if(rpmTopic.topicType == "PROJECT_TYPE5" ){
                        $("#ulBox").find("li[num=0]").css("display","");
                        $("#ulBox").find("li[num=1]").css("display","");
                        $("#ulBox").find("li[num=5]").css("display","");
                        $("#ulBox").find("li[num=4]").css("display","");
                        $("#ulBox").find("li[num=10]").css("display","");
                        $("#ulBox").find("li[num=11]").css("display","");
                        $("#ulBox").find("li[num=12]").css("display","");
                        $("#ulBox").find("li[num=13]").css("display","");
                        $("#ulBox").find("li[num=14]").css("display","");
                        $("#ulBox").find("li[num=2]").css("display","none");
                        $("#ulBox").find("li[num=3]").css("display","none");
                        $("#ulBox").find("li[num=9]").css("display","none");
                        $("#ulBox").find("li[num=6]").css("display","none");
                        $("#ulBox").find("li[num=7]").css("display","none");
                        $("#ulBox").find("li[num=8]").css("display","none");

                        $("#ulBox1").find("div[num=0]").css("display","");
                        $("#ulBox1").find("div[num=1]").css("display","");
                        $("#ulBox1").find("div[num=5]").css("display","");
                        $("#ulBox1").find("div[num=4]").css("display","");
                        $("#ulBox1").find("div[num=10]").css("display","");
                        $("#ulBox1").find("div[num=11]").css("display","");
                        $("#ulBox1").find("div[num=12]").css("display","");
                        $("#ulBox1").find("div[num=13]").css("display","");
                        $("#ulBox1").find("div[num=14]").css("display","");
                        $("#ulBox1").find("div[num=2]").css("display","none");
                        $("#ulBox1").find("div[num=3]").css("display","none");
                        $("#ulBox1").find("div[num=9]").css("display","none");
                        $("#ulBox1").find("div[num=6]").css("display","none");
                        $("#ulBox1").find("div[num=7]").css("display","none");
                        $("#ulBox1").find("div[num=8]").css("display","none");
                    }
                    if (rpmTopic.haveSecondUserId == 0) {
                        $('#headUserId2').val('').attr('user_Id', '').css('background', 'gainsboro').siblings('a').hide()
                        $('.second').hide();
                    } else {
                        $('#headUserId2').css('background', '#fff').siblings('a').show()
                        $('.second').show();
                    }
                    //预计信息
                    $('[name="finalResults"]').val(rpmTopic.finalResults)
                    $('[name="funds"]').val(rpmTopic.funds)
                    $('[name="completionTime"]').val(rpmTopic.completionTime)
                    $('[name="achievementsType"]').val(rpmTopic.achievementsType)
                    form.render()
                    var fileStr = '';
                    if (rpmTopic.attachmentList != undefined && rpmTopic.attachmentList != '') {
                        for (var i = 0; i < rpmTopic.attachmentList.length; i++) {
                            fileStr += '<div url=' + rpmTopic.attachmentList[i].attUrl + ' style="display:inline-block; margin-right:25px; " class="fileDiv"><div class="relative">' +
                                // '   <i class="layui-icon layui-icon-close close"  style="float: right;"></i>' +
                                '  <i class="layui-icon layui-icon-list file" id="file"  attachId="' + rpmTopic.attachmentList[i].attachId + '"  deurl="' + encodeURI(rpmTopic.attachmentList[i].attUrl) + '" ym="' + rpmTopic.attachmentList[i].ym + '" aid="' + rpmTopic.attachmentList[i].aid + '" name="' + rpmTopic.attachmentList[i].attachName + '"  style="font-size: 30px;font-size: 100px; padding-left: 20px;line-height: 140px;"></i>' +
                                '  </div>' +
                                '  <div style="margin:10px;" class="fileName">' + rpmTopic.attachmentList[i].attachName + '(' + rpmTopic.attachmentList[i].size + ')' + '</div></div>';
                        }
                    }
                    $('.content').last().append(fileStr);
                    $('#uploading').parent().siblings('div').show();
                    //附件下载事件
                    $('.fileDiv').click(function () {
                        window.location = '/download?' + $(this).attr('url')
                    })

                } else {
                    tableData('')
                }


            }
        })
        $('#chargetype').siblings('.layui-form-select').hide()

        function tableData(topicId, participator, achievement, task, expect,yexpect) {
            table.render({
                elem: '#participator'
                , data: function () {
                    if (participator != '') {
                        return participator
                    } else {
                        return [{topicId: topicId}]
                    }
                }()
                , toolbar: '#toolbarDemo'
                , defaultToolbar: ['']
                , title: '主参加者信息'
                , cols: [[
                    {type: 'checkbox', fixed: 'left'}
                    , {field: 'topicId', hide: true}
                    , {
                        field: 'memberType', title: '成员类型', templet: function () {
                            var str = '<option>请选择</option>'
                            for (var i = 0; i < memberTypeSel.length; i++) {
                                str += '<option value="' + memberTypeSel[i].dictNo + '">' + memberTypeSel[i].dictName + '</option>'
                            }
                            return ' <select name="memberType" lay-filter="memberType">' + str + '</select>'
                        }
                    }
                    , {field: 'number', title: '编号'}
                    , {
                        field: 'name', title: '参与者姓名', templet: function (obj) {
                            return '<div class="pUsername"><input id="name"  user_Id="" type="text" name="nameId" style="border: none;background: white;height: 100%;width: 100%;" class="search" readonly placeholder="参与者姓名"/>' +
                                '<span style="padding: 5px;color: #999;cursor: pointer;margin-left:-26px"><i class="layui-icon layui-icon-username pRemind"></i></span>' +
                                '</div></div>'
                        }
                    }
                    , {field: 'title', title: '职称'}
                    , {field: 'researchExpertise', title: '研究专长'}
                    , {field: 'education', title: '学历'}
                    , {field: 'workUnit', title: '工作单位'}
                ]]
                , page: true
                , done: function (obj) {
                    var data = obj.data;
                    for (var i = 0; i < data.length; i++) {
                        var select = 'dd[lay-value=' + data[i].memberType + ']';
                        $('[name="memberType"]').eq(i).siblings("div .layui-form-select").find('dl').find(select).click()
                        form.render();
                    }
                    form.on('select(memberType)', function (pr) {
                        var dataindex = $(pr.elem).parents('tr').attr("data-index");
                        data[dataindex].memberType = pr.value;
                    });

                    for (var i = 0; i < obj.data.length; i++) {
                        $('#name').attr('id', 'name' + i)
                        $('#name' + i).val(obj.data[i].userName).attr('user_Id', obj.data[i].name)
                    }
                    // $('.pRemind').click(function () {
                    //     var num = $('.pRemind').index(this)
                    //     $(this).parents('.pUsername').children('input').attr('id', 'name' + num)
                    //     user_id = 'name' + num;
                    //     $.popWindow("/common/selectUser?0");
                    // });

                }
            });
            table.render({
                elem: '#task'
                , data: function () {
                    if (task != '') {
                        return task
                    } else {
                        return [{topicId: topicId}]
                    }
                }()
                , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
                , defaultToolbar: ['']
                , title: '经费预算'
                , cols: [[
                    {type: 'checkbox', fixed: 'left'}
                    , {field: 'topicId', hide: true}
                    , {field: 'researchContents', title: '研究内容', edit: true}
                    , {
                        field: 'expenditureCategory', title: '支出类别', templet: function () {
                            var str = '<option>请选择</option>'
                            for (var i = 0; i < expenditureCategorySel.length; i++) {
                                str += '<option value="' + expenditureCategorySel[i].dictNo + '">' + expenditureCategorySel[i].dictName + '</option>'
                            }
                            return ' <select name="expenditureCategory" lay-filter="expenditureCategory" >' + str + '</select>'
                        }
                    }
                    , {field: 'monovalent', title: '单价', edit: true}
                    , {field: 'number', title: '数量', edit: true}
                    , {field: 'totalFunding', title: '总额', edit: true}
                ]]
                , page: true
                , done: function (res) {
                    var data = res.data;
                    for (var i = 0; i < data.length; i++) {
                        var select = 'dd[lay-value=' + data[i].expenditureCategory + ']';
                        $('[name="expenditureCategory"]').eq(i).siblings("div .layui-form-select").find('dl').find(select).click()
                        form.render();
                    }
                    form.on('select(expenditureCategory)', function (pr) {
                        var dataindex = $(pr.elem).parents('tr').attr("data-index");
                        data[dataindex].expenditureCategory = pr.value;
                    });
                }
            });

            table.render({
                elem: '#achievement'
                , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
                , data: function () {
                    if (achievement != '') {
                        return achievement
                    } else {
                        return [{topicId: topicId}]
                    }
                }()
                , defaultToolbar: ['']
                , title: '近五年成果'
                , cols: [[
                    {type: 'checkbox', fixed: 'left'}
                    , {field: 'topicId', hide: true}
                    , {field: 'number', title: '编号'}
                    , {field: 'achievementsName', title: '课题或成果名称'}
                    , {field: 'author', title: '主持人或第一作者'}
                    // , {field: 'achievementsForm', title: '成果形式'}
                    , {field: 'publicationCompany', title: '课题发布单位或成果发表、出版单位'}
                    , {
                        field: 'publicationTime',
                        title: '立项或发表出版时间',
                    }
                ]]
                , page: true
            });
            table.render({
                elem: '#expect'
                , data: function () {
                    if (expect != '') {
                        return changeData(expect,"1")
                    } else {
                        return [{topicId: topicId}]
                    }
                }()
                , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
                , defaultToolbar: ['']
                , title: '阶段成果信息'
                , cols: [[
                    {type: 'checkbox', fixed: 'left'}
                    , {field: 'topicId', hide: true}
                    , {type: 'numbers', title: '序号'}
                    , {field: 'researchPhase', title: '研究阶段（起止时间）', event: 'researchPhase', data_field: "researchPhase"}
                    , {field: 'researchFindingsName', title: '阶段成果名称', edit: true}
                    , {field: 'formAchievements', title: '成果形式',templet:function () {
                            var str='<option>请选择</option>'
                            for(var i=0;i<achievementsTypeSel.length;i++){
                                str+='<option value="'+achievementsTypeSel[i].dictNo+'">'+achievementsTypeSel[i].dictName+'</option>'
                            }
                            return ' <select name="formAchievements1" lay-filter="formAchievements1" >'+str+'</select>'
                        }}
                    , {
                        field: 'undertaker', title: '承担人', templet: function (obj) {
                            return '<div class="username"><input id="governor" type="text"  user_Id="" name="parentId" style="border: none;background: white;height: 100%;width: 100%;" class="parentId" readonly placeholder="搜索承担人"/>' +
                                '<span style="padding: 5px;color: #999;cursor: pointer;margin-left:-26px"><i class="layui-icon layui-icon-username remind"></i></span>' +
                                '</div></div>'
                        }
                    }
                ]]
                , page: true
                , done: function (obj) {
                    var data=obj.data;
                    for (var i = 0; i < data.length; i++) {
                        var selectF = 'dd[lay-value=' + data[i].formAchievements + ']';
                        $('[name="formAchievements1"]').eq(i).siblings("div .layui-form-select").find('dl').find(selectF).click()
                        form.render();
                    }
                    $('.remind').click(function () {
                        var num = $('.remind').index(this)
                        $(this).parents('.username').children('input').attr('id', 'governor' + num)
                        user_id = 'governor' + num;
                        $.popWindow("/common/selectUser?0");
                    });
                    for (var i = 0; i < obj.data.length; i++) {
                        $('#governor').attr('id', 'governor' + i)
                        $('#governor' + i).val(obj.data[i].undertakerName).attr('user_Id', obj.data[i].undertaker)
                    }
                    form.on('select(formAchievements1)', function(pr){
                        var dataindex=$(pr.elem).parents('tr').attr("data-index");
                        data[dataindex].formAchievements=pr.value;
                    });
                }
            });
            table.render({
                elem: '#fnexpect'
                , data: function () {
                    if (expect != '') {
                        return changeData(expect,"2")
                    } else {
                        return [{topicId: topicId}]
                    }
                }()
                , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
                , defaultToolbar: ['']
                , title: '最终成果信息'
                , cols: [[
                    {type: 'checkbox', fixed: 'left'}
                    , {field: 'topicId', hide: true}
                    , {type: 'numbers', title: '序号'}
                    , {field: 'researchPhase', title: '完成时间', event: 'presearchPhase', data_field: "researchPhase"}
                    , {field: 'researchFindingsName', title: '最终成果名称', edit: true}
                    , {field: 'formAchievements', title: '成果形式',templet:function () {
                            var str='<option>请选择</option>'
                            for(var i=0;i<achievementsTypeSel.length;i++){
                                str+='<option value="'+achievementsTypeSel[i].dictNo+'">'+achievementsTypeSel[i].dictName+'</option>'
                            }
                            return ' <select name="formAchievements" lay-filter="formAchievements" >'+str+'</select>'
                        }}
                    , {
                        field: 'undertaker', title: '负责人', templet: function (obj) {
                            return '<div class="ppusername"><input id="pgovernor" type="text"  user_Id="" name="parentId" style="border: none;background: white;height: 100%;width: 100%;" class="parentId" readonly placeholder="搜索承担人"/>' +
                                '<span style="padding: 5px;color: #999;cursor: pointer;margin-left:-26px"><i class="layui-icon layui-icon-username remind1"></i></span>' +
                                '</div></div>'
                        }
                    }
                ]]
                , page: true
                , done: function (obj) {
                    var data=obj.data;
                    for (var i = 0; i < data.length; i++) {
                        var selectF = 'dd[lay-value=' + data[i].formAchievements + ']';
                        $('[name="formAchievements"]').eq(i).siblings("div .layui-form-select").find('dl').find(selectF).click()
                        form.render();
                    }
                    $('.remind1').click(function () {
                        var num = $('.remind1').index(this)
                        $(this).parents('.ppusername').children('input').attr('id', 'pgovernor' + num)
                        user_id = 'pgovernor' + num;
                        $.popWindow("/common/selectUser?0");
                    });
                    for (var i = 0; i < obj.data.length; i++) {
                        $('#pgovernor').attr('id', 'pgovernor' + i)
                        $('#pgovernor' + i).val(obj.data[i].undertakerName).attr('user_Id', obj.data[i].undertaker)
                    }
                    form.on('select(formAchievements)', function(pr){
                        var dataindex=$(pr.elem).parents('tr').attr("data-index");
                        data[dataindex].formAchievements=pr.value;
                    });
                }
            });
            table.render({
                elem: '#yexpect1'
                , data: function () {
                    if (yexpect != '') {
                        return ychangeData(yexpect,"1")
                    } else {
                        return [{topicId: topicId}]
                    }
                }()
                , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
                , defaultToolbar: ['']
                , title: '成果名称'
                , cols: [[
                    {type: 'checkbox', fixed: 'left'}
                    , {field: 'topicId', hide: true}
                    , {field: 'achievementsName', title: '成果名称', edit: true }
                    , {field: 'achievementWithdrawalMethod', title: '获奖等级', edit: true}
                    , {field: 'expenditureCategory', title: '时间',event: 'researchPhase1', data_field: "expenditureCategory"}
                ]]
                , page: true
                , done: function (obj) {
                    var data=obj.data;
                }
            });
            table.render({
                elem: '#yexpect2'
                , data: function () {
                    if (yexpect != '') {
                        return ychangeData(yexpect,"2")
                    } else {
                        return [{topicId: topicId}]
                    }
                }()
                , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
                , defaultToolbar: ['']
                , title: '会议主题'
                , cols: [[
                    {type: 'checkbox', fixed: 'left'}
                    , {field: 'topicId', hide: true}
                    , {field: 'achievementsName', title: '会议主题',edit: true}
                    , {field: 'achievementWithdrawalMethod', title: '传播对象及层级（区级及以上）', edit: true}
                    , {field: 'expenditureCategory', title: '时间',event: 'researchPhase2', data_field: "expenditureCategory"}
                ]]
                , page: true
                , done: function (obj) {
                    var data=obj.data;
                }
            });
            table.render({
                elem: '#yexpect3'
                , data: function () {
                    if (yexpect != '') {
                        return ychangeData(yexpect,"3")
                    } else {
                        return [{topicId: topicId}]
                    }
                }()
                , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
                , defaultToolbar: ['']
                , title: '专著论文'
                , cols: [[
                    {type: 'checkbox', fixed: 'left'}
                    , {field: 'topicId', hide: true}
                    , {field: 'achievementsName', title: '专著、论文',edit: true }
                    , {field: 'achievementWithdrawalMethod', title: '出版社、刊物', edit: true}
                    , {field: 'expenditureCategory', title: '时间',event: 'researchPhase3', data_field: "expenditureCategory"}
                ]]
                , page: true
                , done: function (obj) {
                    var data=obj.data;
                }
            });
            table.render({
                elem: '#yexpect4'
                , data: function () {
                    if (yexpect != '') {
                        return ychangeData(yexpect,"4")
                    } else {
                        return [{topicId: topicId}]
                    }
                }()
                , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
                , defaultToolbar: ['']
                , title: '培训课程'
                , cols: [[
                    {type: 'checkbox', fixed: 'left'}
                    , {field: 'topicId', hide: true}
                    , {field: 'achievementsName', title: '培训课程、讲座', edit: true}
                    , {field: 'achievementWithdrawalMethod', title: '传播对象', edit: true}
                    , {field: 'expenditureCategory', title: '时间',event: 'researchPhase4', data_field: "expenditureCategory"}
                ]]
                , page: true
                , done: function (obj) {
                    var data=obj.data;
                }
            });
        }



        upload.render({
            elem: '#uploading'
            , url: '../upload?module=rpmTopic'
            , multiple: true
            , accept: 'file' //普通文件
            , done: function (res) {
                var str = '';
                if (res.flag) {
                    str += '<div style="display:inline-block;margin-right: 25px" class="fileDiv"><div class="relative">' +
                        '   <i class="layui-icon layui-icon-close close"  style="float: right;"></i>' +
                        '  <i class="layui-icon layui-icon-list file" id="file"  aid="' + res.obj[0].aid + '"  ym="' + res.obj[0].ym + '" attachId="' + res.obj[0].attachId + '" deurl="' + res.obj[0].attUrl + '" name="' + res.obj[0].attachName + '" fileSize="' + res.obj[0].fileSize + '"   style="font-size: 30px;font-size: 100px; padding-left: 20px;line-height: 140px;"></i>' +
                        '  </div>' +
                        '  <div style="margin:10px;" class="fileName">' + res.obj[0].attachName + '(' + res.obj[0].fileSize + ')' + '</div></div>';
                    $('.content').last().append(str);
                    $('#uploading').parent().siblings('div').show();
                    $('#file').click(function () {
                        window.location = "../../download?" + res.obj[0].attUrl;
                    });
                }
            }
        });

        table.on('tool(participator)', function (obj) {
            var layEvent = obj.event; //获得 lay-event 对应的值
            var datatr = obj.data;//获取行数据
            var tr = obj.tr;
            var me = $(this);
            var data = obj.data;
            if (layEvent == 'edit') {
                if (obj.data.signatureId != '' && obj.data.signatureId != 'undefiend') {
                    layer.confirm('确定要删除该条数据吗？', {
                        btn: ['确定', '取消'],
                        title: "删除"
                    }, function () {
                        $.ajax({
                            type: 'get',
                            url: '/rpmTopic/deleteSignature',
                            dataType: 'json',
                            data: {
                                signatureId: obj.data.signatureId
                            },
                            success: function (res) {
                                if (res.flag == true) {
                                    layer.msg('删除成功！', {icon: 6});
                                    location.reload();
                                } else {
                                    layer.msg('删除失败！', {icon: 6});
                                }
                            }
                        });

                    }, function () {
                        layer.closeAll();
                    });
                } else {
                    var index = tr.attr("data-index");
                    obj.del(tr);
                    data = table.cache["participator"];
                    data.splice(parseInt(index), 1);
                    table.reload('participator', {
                        data: data
                    });
                }
            }

        });

        //预期成果信息
        table.on('toolbar(expect)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            switch (obj.event) {
                case 'addCheckData':
                    var userId = [], userName = [];
                    var achievementsType=[];
                    for (var i = 0; i < $('.parentId').length; i++) {
                        userId.push($('#governor' + i).attr('user_id'))
                        userName.push($('#governor' + i).val())
                        achievementsType.push($('[name="formAchievements"]').eq(i).val())
                    }
//                    debugger
                    var data = table.cache["expect"];
                    var dataEmpty = {topicId: $('.add').attr('topicId')};
                    data.push(dataEmpty);
                    table.reload('expect', {
                        data: data
                    });
                    for (var i = 0; i < userId.length; i++) {
                        $('#governor').attr('id', 'governor' + i)
                        $('#governor' + i).val(userName[i]).attr('user_Id', userId[i])
                        var select = 'dd[lay-value=' + achievementsType[i] + ']';
                        $('[name="formAchievements"]').eq(i).siblings("div .layui-form-select").find('dl').find(select).click()
                        form.render();
                    }
                    break;
            }
            ;
        });
        table.on('tool(achievement)', function (obj) {
            var layEvent = obj.event; //获得 lay-event 对应的值
            var datatr = obj.data;//获取行数据
            var tr = obj.tr;
            var me = $(this);
            var data = obj.data;
            if (layEvent == 'publicationTime') {
                var field = $(this).data('field');
                var index = tr.attr("data-index");
                laydate.render({
                    elem: this.firstChild
                    , show: true //直接显示
                    , closeStop: this
                    , type: 'date'
                    , done: function (value, date) {
                        table.cache["achievement"][index][field] = value
                    }
                });
            } else if (layEvent == 'edit') {
                if (obj.data.forecaseId != '' && obj.data.forecaseId != 'undefiend') {
                    layer.confirm('确定要删除该条数据吗？', {
                        btn: ['确定', '取消'],
                        title: "删除"
                    }, function () {
                        $.ajax({
                            type: 'get',
                            url: '/rpmTopic/deleteForecast',
                            dataType: 'json',
                            data: {
                                forecaseId: obj.data.forecaseId
                            },
                            success: function (res) {
                                if (res.flag == true) {
                                    layer.msg('删除成功！', {icon: 6});
                                    location.reload();
                                } else {
                                    layer.msg('删除失败！', {icon: 6});
                                }
                            }
                        });

                    }, function () {
                        layer.closeAll();
                    });
                } else {
                    var index = tr.attr("data-index");
                    obj.del(tr);
                    data = table.cache["achievement"];
                    data.splice(parseInt(index), 1);
                    table.reload('achievement', {
                        data: data
                    });
                }
            }
        })

        //经费预算
        table.on('toolbar(task)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            switch (obj.event) {
                case 'addCheckData':
                    var topicCategory = []
                    for (var i = 0; i < $('.search').length; i++) {
                        topicCategory.push($('[name="topicCategory"]').eq(i).val())
                    }
                    var data = table.cache["task"];
                    data.push({topicId: $('.add').attr('topicId'), inserSignatures: 1});
                    table.reload('task', {
                        data: data
                    });
                    for (var i = 0; i < topicCategory.length; i++) {
                        var select = 'dd[lay-value=' + topicCategory[i] + ']';
                        $('[name="topicCategory"]').eq(i).siblings("div .layui-form-select").find('dl').find(select).click()
                        form.render();
                    }
                    break;
            }
            ;
        });
        table.on('tool(task)', function (obj) {
            var layEvent = obj.event; //获得 lay-event 对应的值
            var datatr = obj.data;//获取行数据
            var tr = obj.tr;
            var me = $(this);
            var data = obj.data;
            if (layEvent == 'approvalTime') {
                var field = $(this).data('field');
                var index = tr.attr("data-index");
                laydate.render({
                    elem: this.firstChild
                    , show: true //直接显示
                    , closeStop: this
                    , type: 'date'
                    , done: function (value, date) {
                        table.cache["task"][index][field] = value
                    }
                });
            } else if (layEvent == 'edit') {
                if (obj.data.projectNoId != '' && obj.data.projectNoId != 'undefiend') {
                    layer.confirm('确定要删除该条数据吗？', {
                        btn: ['确定', '取消'],
                        title: "删除"
                    }, function () {
                        $.ajax({
                            type: 'get',
                            url: '/rpmTopic/deleteTopices',
                            dataType: 'json',
                            data: {
                                projectNoId: obj.data.projectNoId
                            },
                            success: function (res) {
                                if (res.flag == true) {
                                    layer.msg('删除成功！', {icon: 6});
                                    location.reload();
                                } else {
                                    layer.msg('删除失败！', {icon: 6});
                                }
                            }
                        });

                    }, function () {
                        layer.closeAll();
                    });
                } else {
                    var index = tr.attr("data-index");
                    obj.del(tr);
                    data = table.cache["task"];
                    data.splice(parseInt(index), 1);
                    table.reload('task', {
                        data: data
                    });
                }
            }
        })
        table.on('tool(expect)', function (obj) {
            var layEvent = obj.event; //获得 lay-event 对应的值
            var datatr = obj.data;//获取行数据
            var tr = obj.tr;
            var me = $(this);
            var data = obj.data;
            if (layEvent == 'edit') {
                if (obj.data.expectedResultsId != '' && obj.data.expectedResultsId != 'undefiend') {
                    layer.confirm('确定要删除该条数据吗？', {
                        btn: ['确定', '取消'],
                        title: "删除"
                    }, function () {
                        $.ajax({
                            type: 'get',
                            url: '/rpmTopic/deleteExpectedResults',
                            dataType: 'json',
                            data: {
                                expectedResultsId: obj.data.expectedResultsId
                            },
                            success: function (res) {
                                if (res.flag == true) {
                                    layer.msg('删除成功！', {icon: 6});
                                    location.reload();
                                } else {
                                    layer.msg('删除失败！', {icon: 6});
                                }
                            }
                        });

                    }, function () {
                        layer.closeAll();
                    });
                } else {
                    var index = tr.attr("data-index");
                    obj.del(tr);
                    data = table.cache["expect"];
                    data.splice(parseInt(index), 1);
                    table.reload('expect', {
                        data: data
                    });
                }
            } else if (layEvent == 'researchPhase') {
                var field = $(this).data('field');
                var index = tr.attr("data-index");
                laydate.render({
                    elem: this.firstChild
                    , show: true //直接显示
                    , closeStop: this
                    , range: true
                    , done: function (value, date) {
                        table.cache["expect"][index][field] = value
                    }
                });
            }

        });


        $('.choice').click(function () {
            user_id = $(this).siblings('input').attr('id');
            $.popWindow("../common/selectUser?0");
        });
        $('.empty').click(function () {
            $(this).siblings('input').val('').attr('user_Id', '')
        })

        //保存
        $('.add').click(function () {
            var index = $('.layui-this').index();
            var data, url;
            var topicId = $('.add').attr('topicId')
            switch (index) {
                case 0:
                    if (topicId == undefined) {
                        url = '/rpmTopic/insetCertificate'//添加
                        data = $('#form_basic').serialize()
                            + '&headUserId=' + $('#headUserId').attr('user_id').split(',')[0]
                            + '&headUserId2=' + $('#headUserId2').attr('user_id').split(',')[0]
                            + '&promotionLeader=' + $('#promotionLeader').attr('user_id').split(',')[0]
                            + '&applicationLeader=' + $('#applicationLeader').attr('user_id').split(',')[0]
                            + '&holderName=' + $('#holderName').attr('user_id').split(',')[0]
                            + '&userId=' + $('#userId').attr('user_id').split(',')[0]
                            + '&planId=' + GetQueryString('planId')
                    } else {
                        url = '/rpmTopic/insetCertificate'//修改
                        data = $('#form_basic').serialize()
                            + '&headUserId=' + $('#headUserId').attr('user_id').split(',')[0]
                            + '&headUserId2=' + $('#headUserId2').attr('user_id').split(',')[0]
                            + '&promotionLeader=' + $('#promotionLeader').attr('user_id').split(',')[0]
                            + '&applicationLeader=' + $('#applicationLeader').attr('user_id').split(',')[0]
                            + '&holderName=' + $('#holderName').attr('user_id').split(',')[0]
                            + '&userId=' + $('#userId').attr('user_id').split(',')[0]
                            + '&planId=' + GetQueryString('planId')
                            + '&topicId=' + topicId
                    }
                    break;
                case 1:
                    for (var j = 0; j < $('.pUsername').length; j++) {
                        var indexs = $('#name' + j).parents('tr').attr("data-index");
                        var field = $('#name' + j).parents('td').attr('data-field');
                        table.cache["participator"][indexs][field] = $('#name' + j).attr('user_id').split(',')[0]
                    }
                    url = '/rpmTopic/updateSelective'
                    data = {
                        signatures: JSON.stringify(table.cache["participator"])
                    }
                    break;
                case 2:
                    url = '/rpmTopic/update'
                    data = $('#budgetForm').serialize();
                    data = data + "&planId=" + GetQueryString('planId') + '&topicId=' + topicId;
                    break;
                case 3:
                    url = '/rpmTopic/updateForecast'
                    data = {
                        forecast: JSON.stringify(table.cache["achievement"])
                    }
                    break;
                case 4:
                    url = '/rpmTopic/updateTopices'
                    data = {
                        topices: JSON.stringify(table.cache["task"])
                    }
                    break;
                case 5:
                    url = '/rpmTopic/update'
                    var urlId = '';
                    var urlName = '';
                    for (var i = 0; i < $('.file').length; i++) {
                        urlId += $('.file').eq(i).attr('aid') + '@' + $('.file').eq(i).attr('ym') + '_' + $('.file').eq(i).attr('attachId') + ',';
                        urlName += $('.file').eq(i).attr('name') + '*';
                    }
                    data = {
                        attachmentId: urlId,
                        attachmentName: urlName,
                        planId: GetQueryString('planId'),
                        topicId: topicId
                    }
                    break;
                case 6:
                    for (var j = 0; j < $('.username').length; j++) {
                        var indexs = $('#governor' + j).parents('tr').attr("data-index");
                        var field = $('#governor' + j).parents('td').attr('data-field');
                        table.cache["expect"][indexs][field] = $('#governor' + j).attr('user_id').split(',')[0]
                    }
                    url = '/rpmTopic/updateexpectedResults'
                    data = {
                        results: JSON.stringify(table.cache["expect"])
                    }
                    break;
            }
            if ($('input[name="haveSecondUserId"]:checked').val() == 1) {
                if ($('#userId').val() == '') {
                    layer.msg('请输入申报人 ！', {icon: 2});
                } else if ($('input[name="topicName"]').val() == '') {
                    layer.msg('请输入项目名称！', {icon: 2});
                } else if ($('#topicType').val() == '') {
                    layer.msg('请输入项目类别！', {icon: 2});
                } else if ($('#year').val() == '') {
                    layer.msg('请输入年度！', {icon: 2});
                } else if ($('#headUserId').val() == '') {
                    layer.msg('请输入负责人！', {icon: 2});
                } else if ($('select[name="teachingSubjects"]').val() == '') {
                    layer.msg('请输入任教学科！', {icon: 2});
                } else if ($('select[name="administrativePosition"]').val() == '') {
                    layer.msg('请输入行政职务！', {icon: 2});
                } else if ($('select[name="professionalTitle"]').val() == '') {
                    layer.msg('请输入专业职称！', {icon: 2});
                } else if ($('select[name="sectionType"]').val() == '') {
                    layer.msg('请输入学段！', {icon: 2});
                } else {
                    $.ajax({
                        url: url,
                        data: data,
                        type: 'post',
                        dataType: 'json',
                        success: function (data) {
                            if (data.flag) {
                                layer.msg('保存成功！', {icon: 1}, function () {
                                    // window.close();
                                    window.location.reload()
                                });
                                /*添加成功*/
                            } else {
                                layer.msg('保存失败！', {icon: 2});
                                /*添加失败*/
                            }
                        },

                        error: function (data) {
                            layer.msg('保存失败！', {icon: 2});
                            /*添加失败*/
                        }
                    })
                }
            } else {
                $.ajax({
                    url: url,
                    data: data,
                    type: 'post',
                    dataType: 'json',
                    success: function (data) {
                        if (data.flag) {
                            layer.msg('保存成功！', {icon: 1}, function () {
                                window.location.reload()
//                            window.close();
                            });
                            /*添加成功*/
                        } else {
                            layer.msg('保存失败！', {icon: 2});
                            /*添加失败*/
                        }
                    },

                    error: function (data) {
                        layer.msg('保存失败！', {icon: 2});
                        /*添加失败*/
                    }
                })
            }
        })
        $(document).on('click', '.close', function () {
            var data = $(this).siblings('#file').attr('deUrl')
            var dome = $(this).parents('.fileDiv');
            deleteChatment(data, dome);
        });

        //删除附件
        function deleteChatment(data, element) {

            layer.confirm('<fmt:message code="menuSSetting.th.isdeleteMenu" />？', {
                /*确定要删除吗*/
                btn: ['<fmt:message code="global.lang.ok" />', '<fmt:message code="depatement.th.quxiao" />'], //按钮 /* 确定  取消*/
                title: '<fmt:message code="notice.th.DeleteAttachment" />'/*删除附件*/
            }, function () {
                //确定删除，调接口
                $.ajax({
                    type: 'get',
                    url: '/delete',
                    dataType: 'json',
                    data: data,
                    success: function (res) {

                        if (res.flag == true) {
                            layer.msg('<fmt:message code="workflow.th.delsucess" />', {icon: 6});
                            /*删除成功*/
                            element.remove();
                        } else {
                            layer.msg('<fmt:message code="lang.th.deleSucess" />', {icon: 6});
                            /*删除失败*/
                        }
                    }
                });

            }, function () {
                layer.closeAll();
            });
        }

    });

    function instruct() {
        layer.open({
            type: 1,
            title: '经费预算文字说明',
            btn: ['确定', '取消'],
            shade: 0.5,
            maxmin: true, //开启最大化最小化按钮
            area: ['70%', '90%'],
            content: '<div id="cont" style="margin: 10px">研究经费支出类别可以是：<br/>\n' +
                '1、设备费：用于课题实施过程中购置或试制专用仪器设备，对现有仪器设备进行升级改造，以及租赁外单位仪器设备而发生的费用。<br/>\n' +
                '2、材料费：用于课题实施过程中消耗的各种原材料、辅助材料、低值易耗品等的采购及运输、装卸、整理等费用。<br/>\n' +
                '3、测试化验加工费：用于课题实施过程中支付给外单位（包括依托单位内部独立经济核算单位）的检验、测试、化验及加工等费用。<br/>\n' +
                '4、燃料动力费：用于课题实施过程中直接使用的相关仪器设备、科学装置等运行发生的水、电、气、燃料消耗费用等。<br/>\n' +
                '5、差旅/会议/国际合作与交流费：是指在课题研究过程中开展科学实验（试验）、科学考察、业务调研、学术交流等所发生的外埠差旅费、市内交通费用；为了组织开展学术研讨、咨询以及协调课题研究工作等活动而发生的会议费用；以及课题研究人员出国及赴港澳台、外国专家来华及港澳台专家来内地工作的费用。<br/>\n' +
                '6、出版/文献/信息传播/知识产权事务费：是指在课题研究过程中，需要支付的出版费、资料费（资料收集、整理、复印、翻拍、翻译及印刷等费用）、专用软件购买费、文献检索费、专业通信费、专利申请及其他知识产权事务等费用。<br/>\n' +
                '7、数据采集费：用于课题研究过程中开展问卷调查、田野调查、数据购买、数据分析及相应技术服务购买等费用。<br/>\n' +
                '8、劳务费：用于课题实施过程中支付给参与课题研究的研究生、博士后、访问学者以及课题聘用的研究人员、科研辅助人员等的劳务费用，以及课题聘用人员的社会保险补助费用。课题所在单位在职人员除外。<br/>\n' +
                '9、专家咨询费：用于课题实施过程中支付给临时聘请的咨询专家的费用。\n' +
                '    </div>',
            success: function (res) {
            },
            yes: function (index) {
                layer.closeAll();
            },
            cancel: function (index) {
                layer.closeAll();
            }
        })
    }
    function changeData(arr,ty) {
        var ar = [];
        for(var i = 0;i<arr.length;i++){
            if(arr[i].expectedResultsType == ty){
                ar.push(arr[i]);
            }
        }
        return ar;
    }
    function ychangeData(arr,ty) {
        if(arr!=undefined){
            var ar = [];
            for(var i = 0;i<arr.length;i++){
                if(arr[i].achievementsType == ty){
                    ar.push(arr[i]);
                }
            }
            return ar;
        }

    }
    function changeData(arr,ty) {
        if(arr!=undefined){
            var ar = [];
            for(var i = 0;i<arr.length;i++){
                if(arr[i].expectedResultsType == ty){
                    ar.push(arr[i]);
                }
            }
            return ar;
        }

    }
</script>
